package common

const (
	GIN_CTX_CONFIG_LOGGER = "gin_logger"
	GIN_CTX_CONFIG_CONFIG = "gin_config"
	GIN_CTX_JWT_CLAIM     = "jwt_claim"
	GIN_CTX_JWT_USER_NAME = "jwt_user_name"

	COMMON_STATUS_ENABLE  = "1"
	COMMON_STATUS_DISABLE = "0"
	GIN_CTX_STREE_CACHE   = "stree_cache"
	ERR_ECS_NOT_FOUND     = "ResourceEcs不存在"

	RESOURCE_TYPE_ECS = "ecs"
	RESOURCE_TYPE_ELB = "elb"
	RESOURCE_TYPE_RDS = "rds"

	AGENT_VAR_ENV = "VAR_ENV"
	AGENT_VERSION = "1.0"

	// 任务的执行动作
	AGENT_TASK_ACTION_START  = "start"
	AGENT_TASK_ACTION_KILL   = "kill"
	AGENT_TASK_ACTION_PAUSE  = "pause"
	AGENT_TASK_ACTION_RESUME = "resume"
	AGENT_TASK_ACTION_STOP   = "stop"

	AGENT_TASK_SCRIPT_TYPE_SHELL  = "shell"
	AGENT_TASK_SCRIPT_TYPE_PYTHON = "python"

	// job的状态
	JOB_STATUS_PENING   = "pending"
	JOB_STATUS_RUNNING  = "running"
	JOB_STATUS_PAUSED   = "paused"
	JOB_STATUS_KILLED   = "killed"
	JOB_STATUS_KILLING  = "killing"
	JOB_STATUS_FINISHED = "finished"

	// 任务本地的状态
	AGENT_TASK_STATUS_RUNNING = "running"
	AGENT_TASK_STATUS_KILLED  = "killed"
	AGENT_TASK_STATUS_SUCCESS = "success"
	AGENT_TASK_STATUS_FAILED  = "failed"

	// job 的执行错误策略
	// 遇到1个机器的状态出错，那么暂停整个任务：100机器的任务：发现有节点报错了：暂停下来，去检查，避免影响扩大
	// 直接set job status=paused
	JOB_ONERROR_STRATEGY_PAUSE = "pause"
	// 不管错误，执行完就行 ：啥都不做
	JOB_ONERROR_STRATEGY_IGNORE = "ignore"
	// 终止任务
	//  直接set job status=paused
	JOB_ONERROR_STRATEGY_STOP = "stop"
)

var (
	JOB_ACTION_TRAN_MAP = map[string]string{
		AGENT_TASK_ACTION_START:  "开始",
		AGENT_TASK_ACTION_KILL:   "紧急杀死",
		AGENT_TASK_ACTION_PAUSE:  "暂停",
		AGENT_TASK_ACTION_RESUME: "恢复",
		AGENT_TASK_ACTION_STOP:   "停止",
	}

	JOB_ACTION_NEXT_STATUS_MAP = map[string]string{

		AGENT_TASK_ACTION_START:  JOB_STATUS_RUNNING,
		AGENT_TASK_ACTION_KILL:   JOB_STATUS_KILLING,
		AGENT_TASK_ACTION_PAUSE:  JOB_STATUS_PAUSED,
		AGENT_TASK_ACTION_RESUME: JOB_STATUS_RUNNING,
		AGENT_TASK_ACTION_STOP:   JOB_STATUS_FINISHED,
	}
)
var (
	FLOW_TYPE_Approval = "Approval" // 待我审批的
	FLOW_TYPE_Action   = "Action"

	FLOW_TYPE_MAP = map[string]string{
		FLOW_TYPE_Approval: "审批节点",
		FLOW_TYPE_Action:   "执行节点",
		"Stop":             "结束节点",
	}

	BOOL_COLOUR_MAP = map[bool]string{
		true:  "green",
		false: "red",
	}

	WorkOrderInstanceStatus_MAP = map[string]string{
		WorkOrderInstanceStatusPendingApproval: "待审批的",
		WorkOrderInstanceStatusApprovalReject:  "审批拒绝的",
		WorkOrderInstanceStatusApprovalReject1: "审批拒绝",
		WorkOrderInstanceStatusApprovalPass:    "审批通过",
		WorkOrderInstanceStatusPendingAction:   "待执行的",
		WorkOrderInstanceStatusUnderAction:     "执行中",
		WorkOrderInstanceStatusFinished:        "已执行完成的",
	}

	ApprovalActionPass   = "pass"   // 审批通过
	ApprovalActionReject = "reject" // 审批拒绝
	ApprovalActionMap    = map[string]string{
		ApprovalActionPass:   "",
		ApprovalActionReject: "",
	}

	COMMON_SHOW_MAP = map[string]bool{
		"1": true,
		"0": false,
	}

	WorkOrderInstanceQueryModeCreate   = "mine"             // 我的
	WorkOrderInstanceQueryModeAll      = "all"              // 全部
	WorkOrderInstanceQueryModeApproval = FLOW_TYPE_Approval // 待审批
	WorkOrderInstanceQueryModeAction   = FLOW_TYPE_Action   // 待执行

	WorkOrderInstanceStatusPendingApproval = "pendingApproval" // 待审批的
	WorkOrderInstanceStatusApprovalReject  = "approvalReject"  // 审批拒绝的
	WorkOrderInstanceStatusApprovalReject1 = "reject"          // 审批拒绝
	WorkOrderInstanceStatusApprovalPass    = "pass"            // 审批通过
	WorkOrderInstanceStatusPendingAction   = "pendingAction"   // 待执行的
	WorkOrderInstanceStatusUnderAction     = "underAction"     // 执行中
	WorkOrderInstanceStatusFinished        = "finished"        // 已执行完成的
)
